$(function () {
    const $phone = $("input:eq(0)"); // 验证
    const $name = $("input:eq(1)");
    const $passwd = $("input:eq(2)");
    const $email = $("input:eq(3)");
    const $phone1 = $("input:eq(4)");
    const $regtime = $("input:eq(5)");
    const $logintime = $("input:eq(6)");
    const $labelPhone = $("#label-phone");

    const $res = $("#res");

    findUser($("span:eq(1)"), $res, $phone, $labelPhone, $name, $passwd, $email, $phone1, $regtime, $logintime, null, null, null, null);

    let flag1 = true;
    let windowId;
    let timeout1;
    $passwd.hover(function () {
        if (flag1) timeout1 = setTimeout(function () {
            windowId = layer.tips("点我可以显示密码", "#passwd", {tips: 1, time: 0});
            flag1 = false;
        }, 5000);
    }, function () {
        if (timeout1 !== undefined) clearTimeout(timeout1);
        timeout1 = undefined;
        if (windowId !== undefined) layer.close(windowId);
        windowId = undefined;
    })
    $passwd.click(function () {
        flag1 = false;
        if (windowId !== undefined) layer.close(windowId);
        windowId = undefined;
        if ($passwd.prop('type') === 'password')
            $passwd.prop('type', 'text');
        else $passwd.prop('type', 'password');
    })

    $("span:eq(3)").click(function () {
        let windowId = layer.load();
        $.getJSON("/admin/views/user/delete.do", {id: json.id}, function (data) {
            layer.close(windowId);
            layer.msg(data.message);
            if (data.status === 0) {
                json.waitingForSamePhone = false;
                $("input").val('');
                $res.hide();
            }
        });
        return false;
    });
});